package com.maoye.ossp.biz.contract.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.hotent.base.api.query.QueryFilter;
import com.maoye.ossp.biz.contract.entity.ContractLog;
import com.maoye.ossp.biz.contract.service.IContractLogService;
import com.maoye.ossp.common.entity.Page;
import com.maoye.ossp.common.web.BaseController;
/**
 * 合同日志controller
 * @author yanzy
 *
 */
@Controller
@RequestMapping(value = "/biz/contract/contractlog")
public class ContractLogController extends BaseController{
	
	@Resource
	private IContractLogService contractLogService;
	
	/**
	 * 查询合同日志列表
	 * @param contractLog
	 * @param request
	 * @param model
	 * 
	 */
	@RequestMapping(value = "/list")
	public String list(ContractLog contractLog,HttpServletRequest request
					,Model model){
		QueryFilter queryFilter = getQuerFilter(request, contractLog);
		Page<ContractLog> page = (Page<ContractLog>)contractLogService
				.find(queryFilter);
		model.addAttribute("page", page);
		model.addAttribute("contractLog", contractLog);
		return "/biz/contract/contractlog/list";
	}
	
	/**
	 * 查询详细合同日志信息
	 * @param id
	 * @param model
	 * 
	 */
	@RequestMapping(value = "/{id}/view")
	public String view(@PathVariable String id,Model model){
		ContractLog contractLog = contractLogService.get(id);
		model.addAttribute("contractLog", contractLog);
		return "/biz/contract/contractlog/view";
	}
	
	/**
	 * 删除合同日志记录
	 * @param id
	 * @param redirectArributes
	 * 
	 */
	@RequestMapping(value = "/{id}/remove")
	public String remove(@PathVariable String id,RedirectAttributes redirectAttributes){
		contractLogService.expurgateLog(id);
		addMessage(redirectAttributes, "删除日志成功");
		return "redirect:/biz/contract/contractlog/list";
	}
	
}
